package com.cskaoyan.service.wx_brand;

import com.cskaoyan.bean.mall.brand.Brand;
import com.cskaoyan.bean.mall.brand.BrandExample;
import com.cskaoyan.bean.wx_brand.base.BrandPageData;
import com.cskaoyan.bean.wx_brand.base.BrandParam;
import com.cskaoyan.bean.wx_brand.exception.BrandParamException;
import com.cskaoyan.mapper.mall.BrandMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author liXiaoFei
 * @date 2021/10/21 16:21
 */
@Service
public class WxBrandServiceImpl implements WxBrandService {

    @Autowired
    BrandMapper brandMapper;

    @Override
    public BrandPageData queryBrand(BrandParam brandParam) {
        BrandExample example = new BrandExample();
        List<Brand> brands = brandMapper.selectByExample(example);
        return BrandPageData.ok(brands);
    }

    @Override
    public Brand queryBrandById(Integer id) throws BrandParamException {
        if (id == null) throw new BrandParamException();
        Brand brand = brandMapper.selectByPrimaryKey(id);
        if (brand == null) throw new BrandParamException();
        return brand;
    }


}
